package com.topics;

import org.springframework.amqp.rabbit.annotation.Exchange;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.QueueBinding;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.stereotype.Component;

@Component
public class TopicsCustomers {
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//不指定名字表示：创建临时队列
                    exchange = @Exchange(name = "topics",type ="topic" ),//绑定交换机
                    key = {"user.*","product.#"}
            )
    })
    public void customer1(String message){

        System.out.println("动态路由Topics消费者1："+message);
    }
    @RabbitListener(bindings = {
            @QueueBinding(
                    value = @Queue,//不指定名字表示：创建临时队列
                    exchange = @Exchange(name = "topics",type ="topic" ),//绑定交换机
                    key = {"user.#","order.*"}
            )
    })
    public void customer2(String message){
        System.out.println("动态路由Topics消费者2："+message);
    }
}
